export const isMobile = () => {
  const mobileExg =
    /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
  return mobileExg.test(navigator.userAgent)
}

// 过滤时间格式为2022-20-12 22:02:08格式
export const formatterTime = (time) => {
  let date = new Date(time)
  let year = minNine(date.getFullYear())
  let month = minNine(date.getMonth() + 1)
  let dates = minNine(date.getDate())
  let hour = minNine(date.getHours())
  let min = minNine(date.getMinutes())
  let second = minNine(date.getSeconds())
  return `${year}-${month}-${dates} ${hour}:${min}:${second}`
}

// 小于9补零
const minNine = (data) => {
  data = parseInt(data)
  if (data < 10) {
    data = '0' + data
  }
  return data
}
